
import fetch from 'isomorphic-fetch'
import loading from '../components/loading'

module.exports = (url)=>{
  loading.show()
  
  var headers = new Headers();
  headers.append('Authorization',localStorage.getItem('Authorization'))
  return fetch(url,{
    credentials: 'same-origin',
    headers:headers
  })
  .then(res=>{
    return res.json();
  })
  .then(res=>{
    loading.hide()
    
    return res;
  })
  .catch(e=>{
    return { code:-1,data:{},message:"请求失败，请重新操作"}
    if(actions) actions.showAlert({text:'请求失败，请重新操作',code:0})
  })
}



